// @ts-ignore
import { initEnv } from '@cqdcg/admin/utils/env';
initEnv(import.meta.env);
// @ts-ignore
import { setupPinia } from '@cqdcg/admin/stores/index';

import router from '/@/router/index';
import { PullRefresh } from 'vant';
import 'amfe-flexible';
// @ts-ignore
import VForm3 from '@cqdcg/formdesigner';
import '@cqdcg/formdesigner/dist/designer.style.css';
import { loadCustomWidgets } from '/@/components/form-custom/custom-widgets-loader.js';
import '/@/theme/tailwind.css';
import '/@/theme/index.scss';
import 'vant/lib/index.css'; // 引入 Vant 的样式文件
import Vant from 'vant';
import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';
import { createApp } from 'vue';
import App from './App.vue';
// @ts-ignore
import { initService } from '@cqdcg/admin/utils/request';

import { setToken } from '/@/utils/utils';

import vhCheck from 'vh-check';

const initApp = async () => {
	let service = await initService();
	const app = createApp(App);
	vhCheck();
	setupPinia(app);
	app.use(router);
	app.use(PullRefresh);
	app.use(VForm3); // 表单设计
	app.use(ElementPlus); // ElementPlus 全局引入
	app.use(Vant);
	loadCustomWidgets(app);
	// window.axios = service;
	// @ts-ignore
	window.service = service;
	await setToken();
	app.mount('#app');
};

initApp();
